﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ChangePassword.aspx.cs" Inherits="JKF.Web.Sys.Module.ChangePassword" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>修改密码</title>
        <%= RegScript("~/js/jquery.1.5.js")%>
        <%= RegScript("~/js/jquery.js")%>  
        <%= RegScript("~/js/jquery.nhis.js")%>
        <%= RegScript("~/js/jquery.rchis.js")%>
        <%=RegScript("~/js/jquery.validate.js")%> 
        <%=RegStyle("~/js/suggest/jquery.suggest.css")%>
        <%= RegScript("~/js/jquery-ui-custom.min.js")%>
        <%= RegScript("~/js/css.js")%> 
        <%= RegScript("~/js/Common.js")%>
        <%= RegScript("~/js/Jquery.commonGrid.js")%>
        <script src="../../js/Uppop/tipswindown2.js"  type="text/javascript"></script> 
        <link href="../../App_Themes/Theme2/Include.css"   rel="stylesheet" type="text/css" />
         
    
    <script type="text/javascript">
        var ntEmpt = /^[^ ]+$/;
        $(function () {
            check(); //调用检查输入

            $("#BtnSave").click(function () {
                saveModule();
            });
            $('#txtOldPwd,#txtNewPwd,#txtSure').keyup(function (event) {
                enterHandler(event, 'BtnSave');
            });
             
        });
         
        // 检查输入
        function check() {
            alxVr.push({ id: "txtOldPwd",
                rule: function (jd) {
                    if (!ntEmpt.test(jd.val())) {
                        this.msg = "请输入原密码."; return false;
                    } return true;
                }
            });
            alxVr.push({ id: "txtNewPwd",
                rule: function (jd) {
                    if (!ntEmpt.test(jd.val())) {
                        this.msg = "请输入新密码."; return false;
                    } else if ($.FxNull(jd.val(), "").length > 20 || $.FxNull(jd.val(), "").length < 6) {
                        this.msg = "新密码长度必须在6-20个字符以内！"; return false;
                    } else if (jd.val() === $('#txtOldPwd').val()) {
                        this.msg = "新密码不能与原来密码相同！"; return false;
                    }
                     return true;
                }
            });
            alxVr.push({ id: "txtSure",
                rule: function (jd) {
                    if (!ntEmpt.test(jd.val())) {
                        this.msg = "请输入确认密码."; return false;
                    } else if (jd.val() != $('#txtNewPwd').val()) {
                        this.msg = "两次输入的密码不一致，请重新输入！";  
                        return false;
                    }
                    return true;
                }
            });
            
            $.validateBind();
        }
        // 保存店面信息
        function saveModule() {
            if (!$.validateAll()) {
                if ($(".alxv-failed").size() > 0) {
                    $(document).scrollTop($(".alxv-failed").eq(0).scrollTop());
                }

                return;
            }
            if (!confirm("确定要修改密码吗? 修改成功后需要你重新登录本系统。")) {
                return;
            }
            $('#BtnSave').attr('disabled', 'disabled');
            $.ajax({
                type: 'post',
                dataType: 'json',
                url: '/do/Sys/SysUser.do',
                data: { ActionName: 'ChangePassWord', OldPwd: $('#txtOldPwd').val(), NewPwd: $('#txtNewPwd').val() },
                success: function (data) {
                    if (data.IsSucc) {
                        alert("修改成功，请重新登录！");
                        //密码修改成功后直接跳转至登录页面
                       parent.window.location.href = '/Logout.ashx';
                    }
                    else {
                        alert(data.Message);
                    }
                    $('td input').val('').eq(0).focus();
                    $('#BtnSave').removeAttr('disabled');
                }
            });
        }
        //检查包含特殊字符
        function checkPwdIsRight(s) {
            var patrn = /^\w+$/;
            if (!patrn.exec(s)) return false
            return true
        }
        function getResult(s) {
            if (s.length < 4) {
                return 0;
            }
            var ls = 0;
            if (s.match(/[a-z]/ig)) {
                ls++;
            }
            if (s.match(/[0-9]/ig)) {
                ls++;
            }
            if (s.match(/([^ a-z0-9])/ig)) {
                ls++;
            }
            if (s.length < 6 && ls > 0) {
                ls--;
            }
            return ls;
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
       <div class="warrper_body"> 
           <div class="index">
                <div class="bg_white"  style="margin:32px auto; width:834px;height:400px">
                       <table width="100%" border="0" style=" " cellspacing="0" cellpadding="0" class="common_table_noborde">
                             <tr>
                                <td width="30%" style="text-align:right;">
                                    用户名：
                                </td>
                                <td width="75%" style="text-align:left;">
                                    <asp:Label ID="lblUserName" CssClass="f12red" runat="server" Text="Label"></asp:Label>
                                </td>
                        
                            </tr>
                            <tr>
                                <td width="25%" style="text-align: right;">
                                    原密码：
                                </td>
                                <td width="75%" style="text-align: left;"> 
                                    <input type="password" id="txtOldPwd" class="passwordinputWidth" value=""   maxlength="20"/>
                                </td>
                            </tr>
                            <tr>
                                <td width="25%" style="text-align: right;">
                                    新密码：
                                </td>
                                <td width="75%" style="text-align: left;"> 
                                      <input type="password" id="txtNewPwd" class="passwordinputWidth" value=""   maxlength="20"/>
                                </td>
                            </tr>
                            <tr>
                                <td width="25%" style="text-align: right;">
                                    确认密码：
                                </td>
                                <td width="75%" style="text-align: left;">
                                    <input type="password" id="txtSure" class="passwordinputWidth" value=""   maxlength="20"/> 
                                </td>
                            </tr>
                            <tr>
                                <td width="25%" style="text-align: right;">
                                </td>
                                <td width="75%" style="text-align: left;">
                                    <input id="BtnSave" type="button"  class="common_btn_confirm mr30 mb25" value="" /> 
                             
                                </td>
                            </tr>
                        </table>

             
                 </div>
          </div>
     </div>
    </form>
</body>
</html>
